<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>变量的作用域练习题</title>
</head>
<body>
    <script>
    var name ='a';//全局变量
    console.log(name);//a
    function f2(){
        console.log(name);//a
    }
    f2();

    function f1(){
        //a 局部变量
        //b c 全局变量
        var a; //var a=9;初始化变量不会提升
        a = b = c = 9;
        console.log('a' + a);//9
        console.log('b' + b);//9
        console.log('c' + c);//9
    }
    f1();
    console.log('cc' + c);//9
    console.log('bb' + b);//9
    console.log('aa' + a);//a is not defined
    
    </script>
</body>
</html>